/*
 * @Author: yangzonglong
 * @Date: 2020-06-17 15:02:01
 * @version: v1.0.0
 * @Descripttion: 
 * @LastEditors: TLL
 * @LastEditTime: 2021-05-06 10:20:48
 * @Auditor: 
 */
import { FormProps as AntdFormProps } from 'antd/lib/form/Form';
import { Rule, FormInstance } from 'rc-field-form/lib/interface';
import React from 'react';
import { SelectProps } from './../select/interface';

export type Type = 'input' | 'inputNumber' | 'datePicker' | 'consoleSelect' | 'switch' | 'radio' |
  'textArea' | 'MoneyInputNumber' | 'FileUploadInput' | 'ModalTableInModelInput' | 'select' | 'autoComplete' | string

export interface FormItemProps {
  name: string;
  label?: string;
  type?: Type;
  required?: boolean | string;
  disabled?: boolean | string;
  ghost?: boolean | string;
  options?: SelectProps | any;
  rules?: Rule[] | string;
  bindField?: string;
  placeholder?: string;
  span?: number
}

interface RenderOptions {
  id: string;
  placeholder?: string;
}

export type Extra = Array<{ name: string; render(options: RenderOptions): React.ReactNode }>;

export interface FormxProps extends AntdFormProps {
  formItems: FormItemProps[];
  disabled?: boolean;
  groupNumber?: number;
  initialValues?: object;
  onValuesChange?(changedValues: any, allValues: any): void | object;
  noMergeInitialValues?: boolean;
  extra?: Extra;
  noLangFormUi?: boolean // 为false时 则不自动根据语言处理 form label 样式
  children?: React.ReactNode
}

export interface FormxRefProps extends FormInstance { }